package com.lipaluma.test.db.annotations.clean;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import com.lipaluma.test.db.internal.DialectEnum;
import com.lipaluma.test.db.internal.clean.CleanStrategy;

/**
 * Clean all the schema of the database. The clean can be done by TRUNCATE or by DELETE.<br>
 * 
 * The clean will take care of foreign keys and will clean all tables in good order.
 * 
 * @author Mario
 */
@Documented
@Inherited
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface CleanSchema {

	/**
	 * List of schemas to clean
	 * Liste des schémas de la base à nettoyer.<br/>
	 * 
	 * If not defined, it will take the default schema
	 */
	String[] value() default {};
	
	/**
	 * clean before the test. By default, it's true.
	 * @return
	 */
	boolean before() default true;
	
	/**
	 * clean after the test, By default, it's false.
	 * @return
	 */
	boolean after() default false;
	
	/**
	 * Strategy of the clean : 
	 * <ul>
	 * 	<li>TRUNCATE : truncate tables will be used to clean tables. Care to define the good dialect</li>
	 * 	<li>DELETE : deletes tables by using the request DELETE FROM ...</li>
	 * </ul>
	 * 
	 * Default is TRUNCATE.
	 * @return
	 */
	CleanStrategy strategy() default CleanStrategy.TRUNCATE;
	
	/**
	 * nama of the datasource to clean
	 * @return
	 */
	String dataSource() default "";

	/**
	 * Define the dialect to use the good syntax for the truncate table.<br/>
	 * Default is Mysql
	 * @return
	 */
	DialectEnum dialect() default DialectEnum.MYSQL;

	/**
	 * Clean severals schemas
	 * @author Mario
	 *
	 */
	@Documented
	@Inherited
	@Target({ElementType.METHOD, ElementType.TYPE})
	@Retention(RetentionPolicy.RUNTIME)
	public @interface List {
		CleanSchema[] value();
	}
}
